package com.gr.util;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyHandlerExceptionResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        /**可以加if判断控制输出到控制台的信息
         * 如果在地址栏输入 selectAll.do1是语法错误，报的是500异常，不会在控制台输出
         * selectAll1.do会报404异常，在控制台打印异常信息
         */

            ex.printStackTrace();


        //其他异常，统一跳转到404jsp
        return new ModelAndView("forward:/404.jsp");
    }
}
